Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listen on printing shortcut to open print view for printing #544

Closed
wants to merge 1 commit into from

Conversation

susnux
Copy link
Contributor

@susnux susnux commented Feb 10, 2023

📝 Summary

Listen on CTRL + P (or CMD respectivly), then cancel printing the collective but open the print view to the correct styling get applied.
Moreover I changed the target name of the new tab / window, so the printing view gets recycled for all printing tasks to not spam the users tabs.

🖼️ Screenshots

🏚️ Before 🏡 After
image

🏁 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits
  • Tests (unit, integration and/or end-to-end) passing and the changes are covered with tests
  • Documentation (README or documentation) has been updated or is not required

@susnux susnux added enhancement New feature or request 3. to review labels Feb 10, 2023
@susnux susnux requested review from azul and mejo- February 10, 2023 16:24
@cypress
Copy link

cypress bot commented Feb 10, 2023

Passing run #983 ↗︎

0 76 0 0 Flakiness 0

Details:

Listen on printing shortcut to open print view for printing
Project: Collectives Commit: 50d77bcbb2
Status: Passed Duration: 03:58 💡
Started: Jul 28, 2023 5:03 PM Ended: Jul 28, 2023 5:07 PM

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

Copy link
Collaborator

@max-nextcloud max-nextcloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Just one minor fix to prevent overwriting other keyboard shortcuts.

(Have not tried it - just from the sourcecode it seems ctrl+shift+P migth also be affected.)

src/views/CollectiveView.vue Outdated Show resolved Hide resolved
Copy link
Member

@mejo- mejo- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @susnux! This would make it impossible to print single pages though, no? Or am I missing something?

src/views/CollectiveView.vue Outdated Show resolved Hide resolved
@susnux susnux force-pushed the fix/printing-background branch 2 times, most recently from 0fce9d0 to ff789f4 Compare February 13, 2023 14:01
@mejo-
Copy link
Member

mejo- commented Feb 14, 2023

Thanks @susnux! This would make it impossible to print single pages though, no? Or am I missing something?

@susnux what's your take on the question of printing a single page?

src/store/store.js Outdated Show resolved Hide resolved
@susnux
Copy link
Contributor Author

susnux commented Feb 15, 2023

🤦 I did not noticed that you currently print the whole collective with subpages...

The idea was to not duplicate places with printing specific styling. So forward to the export view, I am currently thinking about resolving this by adding a property to the print view to only print the current page, do you think this is a acceptable solution?

@mejo-
Copy link
Member

mejo- commented Feb 15, 2023

The idea was to not duplicate places with printing specific styling. So forward to the export view, I am currently thinking about resolving this by adding a property to the print view to only print the current page, do you think this is a acceptable solution?

Yeah, in the long run I would like to add a dedicated export view that allows to print or export pages to PDF. The default should be to export the whole collective, but it should be possible to (un)select specific pages. Unfortunately this is not very high on the priority list. See #463.

Your intermediate solution to allow printing only a specific page in the print view sounds good to me!

@susnux
Copy link
Contributor Author

susnux commented Apr 16, 2023

I am currently try to work on this again, I think the best way to solve this is to add subpage support for the export view as well. But this will require quite some work on that view (as I am not that into the collectives app structure). I hope to get this working this month :)

@susnux susnux requested a review from mejo- April 18, 2023 14:52
@susnux susnux force-pushed the fix/printing-background branch 2 times, most recently from bb18d7c to 1c04476 Compare April 18, 2023 15:00
@susnux
Copy link
Contributor Author

susnux commented Apr 18, 2023

It is now possible to use the print view to only print subpages, this is now also used for CTRL+P and there is a print menu entry in the pages action menu.

@susnux susnux force-pushed the fix/printing-background branch 2 times, most recently from de87d59 to b60cd65 Compare April 18, 2023 15:22
@susnux susnux force-pushed the fix/printing-background branch 2 times, most recently from 9aa720a to afbc924 Compare June 26, 2023 16:17
@susnux
Copy link
Contributor Author

susnux commented Jun 26, 2023

@mejo- Any idea why only one cypress ci was successfully?

* Listen on printing shortcut to open print view for printing
* Hide toastify dialogs when printing
* Make sure background is removed

Signed-off-by: Ferdinand Thiessen <[email protected]>
@susnux
Copy link
Contributor Author

susnux commented Jul 28, 2023

@mejo- Any idea why only one cypress ci was successfully?

Never mind CI is green after rebasing 🎉

@pjrobertson
Copy link
Contributor

The images in the initial PR post look like this also solves the problem of the content being moved on to the 2nd page when it's longer than 1 page (no page break). I find that every collective I try to print longer than a specific amount has this issue - the title on the first page and content on the 2nd page. Hopefully this can be merged soon!

Screen Region 2023-08-08 at 18 26 12 1
Screen Region 2023-08-08 at 18 26 16 1

@@ -142,6 +142,7 @@ export default {
'isCollectiveAdmin',
'isPublic',
'loading',
'printLink',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a leftover, printLink() is defined as computed property below and not available as getter from the store.

Copy link
Member

@mejo- mejo- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gave this a quick test. Unfortunately I ran into several issues:

  • It doesn't work for first-level pages because they somehow get a double slash in the URL.
  • It doesn't work for second-level pages (and first-level pages with the double slash removed). Console error is: this.currentPage is undefined.

@@ -166,6 +167,10 @@ export default {
? generateUrl(`/apps/collectives/p/${this.shareTokenParam}/print/${this.collective.name}`)
: generateUrl(`/apps/collectives/_/print/${this.collective.name}`)
},

unshareIcon() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a leftover or copy/paste error as well. unshareIcon() is not used here.

@@ -171,6 +171,14 @@ export default {
return state.pages.find(p => (p.parentId === parentId && p.title === TEMPLATE_PAGE))
},

pagePrintLink: (state, get) => (page) => {
const path = [page.collectivePath.split('/').at(-1), page.filePath.split('/'), page.fileName]
if (path.at(-1) === 'Readme.md') path.splice(-1, 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use these one-line if () ... syntax so far, I'd prefer to stick to if () { \n ... \n }` 😬

Same for the following two lines.

printKeyHandler(event) {
// Handle `CTRL+P` or `CMD+P` but ensure ALT or SHIFT are NOT pressed (e.g. CTRL+SHIFT+P is new private tab on firefox)
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === 'p' && !(event.altKey || event.shiftKey)) {
if (!this.currentPage) return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@@ -37,11 +37,13 @@ const routes = [
path: '/_/print/:collective',
component: CollectivePrintView,
props: (route) => route.params,
children: [{ path: ':page*' }],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give me a quick hint what you want to achieve here? Maybe I oversaw something, but I don't see where this would be used 🤔

mejo- added a commit that referenced this pull request Oct 27, 2023
Also resolves the problem with empty page before first page content on
Firefox.

Fixes: #544
Fixes: #542

Signed-off-by: Jonas <[email protected]>
mejo- added a commit that referenced this pull request Oct 27, 2023
Also resolves the problem with empty page before first page content on
Firefox.

Fixes: #544
Fixes: #542

Signed-off-by: Jonas <[email protected]>
@mejo- mejo- mentioned this pull request Oct 27, 2023
4 tasks
@mejo-
Copy link
Member

mejo- commented Oct 30, 2023

Closing this PR now that we have fixes from #971.

@mejo- mejo- closed this Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Printing: Collective title always on blank first page Improve printing layout
4 participants